//
//  WebviewProgressLine.m
//  WebProgressLineDemo
//
//  Created by aa on 2018/4/8.
//  Copyright © 2018年 杨旭. All rights reserved.
//
#define kScreenWidth      [UIScreen mainScreen].bounds.size.width

#import "WebviewProgressLine.h"

@implementation WebviewProgressLine


- (void)setLineColor:(UIColor *)lineColor {
    _lineColor = lineColor;
    self.backgroundColor = lineColor;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.hidden = YES;
        self.backgroundColor = [UIColor whiteColor];

    }
    return self;
}


- (void)startLoadingAnimation {
    self.hidden = NO;
    self.width = 0.0;
    __weak UIView *weakSelf = self;
    [UIView animateWithDuration:0.4 animations:^{
        weakSelf.width = kScreenWidth * 0.4;
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.4 animations:^{
            weakSelf.width = kScreenWidth * 0.8;
        }];
    }];
}

- (void)endLoadingAnimation {
    __weak UIView *weakSelf = self;
    [UIView animateWithDuration:0.2 animations:^{
        weakSelf.width = kScreenWidth;
    } completion:^(BOOL finished) {
        weakSelf.hidden = YES;
    }];
}


@end
